\\
Computing subgradients can be done recursively, and the procedure is analogous to the chain rule for differentiable functions. For each library function, we implemented a method that computes its subgradient at a given point. Subgradients of more complicated expressions can be computed using the composition rule:
\begin{itemize}
\item Let $f(x) = h(f_1(x), \ldots, f_k(x))$ with $h$ convex non-decreasing,
  $f_i$ convex.
\item Find $c \in \partial h(f_1(x), \ldots, f_k(x))$,  $g_i \in \partial
  f_i(x)$
\item Then, $g = c_1 g_1 + c_2 g_2 + \cdots + c_k g_k$ is a subgradient of $f$ at $x$.
\end{itemize}
